import App from './App'
import Vue from 'vue'
import api from "common/js/common.js"
import http from "common/js/http.js"
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
uni.$u.config.unit = 'rpx'
// #ifndef VUE3
Vue.config.productionTip = false
Vue.prototype.$http = api
App.mpType = 'app'
Vue.prototype.version = "dev"; //版本
switch (App.globalData.version) {
	case "dev":
		Vue.prototype.http = "" //测试
		//测试
		break;
	case "uat":
		//正式
		Vue.prototype.http = "https://signup.yfzxzjysg.top/" //正式
		break;
	case "localhost":
		//本地
		// Vue.prototype.http = ""; //本地

		break;
	default:
		// Vue.prototype.http = "" //测试
		break;
}
try {
  function isPromise(obj) {
    return (
      !!obj &&
      (typeof obj === "object" || typeof obj === "function") &&
      typeof obj.then === "function"
    );
  }

  // 统一 vue2 API Promise 化返回格式与 vue3 保持一致
  uni.addInterceptor({
    returnValue(res) {
      if (!isPromise(res)) {
        return res;
      }
      return new Promise((resolve, reject) => {
        res.then((res) => {
          if (res[0]) {
            reject(res[0]);
          } else {
            resolve(res[1]);
          }
        });
      });
    },
  });
} catch (error) { }
// 引入自定义小程序分享的封装
import share from "@/common/js/share.js"
Vue.mixin(share)
const app = new Vue({
  ...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif